<!--_meta 作为公共模版分离出去-->
<?php 
require_once 'comm/_meta.php';
require_once 'comm/chkLoginState.php';
?>
<!--/meta 作为公共模版分离出去-->

<title>实训中心考勤OA</title>
<meta name="keywords" content="实训中心考勤OA">
<meta name="description" content="实训中心考勤OA">
</head>
<body>
<!--_header 作为公共模版分离出去-->
<?php require_once 'comm/_header.php';
	require_once 'comm/_menu.php';
	$info = new DB();
	//echo 'select * from leave_info where class_name = '.$_SESSION['login_class'];exit;
	$res = $info->query('select * from leave_info where class_name = "'.$_SESSION['login_class'].'"');
	$res_list = $info->query('select * from leave_info where class_name = "'.$_SESSION['login_class'].'" and ass_check = 0');
	if ($_SESSION['login_role']=='stuManager'){}else if ($_SESSION['login_role']=='stuAdmin'){}else if ($_SESSION['login_role']=='manager'){}else if ($_SESSION['login_role']=='instructor'){}
	//('leave_info',' where stu_id = ');
	
?>
<section class="Hui-article-box">
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 
		首页 <span class="c-gray en">&gt;</span> 
		考勤管理 <span class="c-gray en">&gt;</span> 
		部门请假单 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
	<div class="Hui-article">
		<article class="cl pd-20">
			<div class="text-c"> 日期范围：
				<input type="text" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'logmax\')||\'%y-%M-%d\'}'})" id="logmin" class="input-text Wdate" style="width:120px;">
				-
				<input type="text" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'logmin\')}',maxDate:'%y-%M-%d'})" id="logmax" class="input-text Wdate" style="width:120px;">
				
				<button name="" id="" class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
			</div>

	 <div id="tab_demo" class="HuiTab">
      <div class="tabBar clearfix"><span>待审核列表</span><span>全部列表</span></div>
      <div class="tabCon">
      		<div class="mt-20">
				<table class="table table-border table-bordered table-bg table-hover table-sort">
					<thead>
						<tr class="text-c">
							<th width="20">ID</th>
							<th width="60">申请日期</th>
							<th width="60">姓&nbsp;&nbsp;名</th>
							<th width="60">开始时间</th>
							<th width="60">结束时间</th>
							<th width="30">申请天数</th>
							<th width="30">请假类型</th>
							<th width="30">审核状态</th>
							<th width="30">操作</th>
						</tr>
					</thead>
					<tbody>
					<?php foreach ($res_list as $k=>$v){ 
						$sr=0;
						if ($v['ass_check']){$sr = 20;}
						if ($v['man_check']){$sr = 40;}
						if ($v['lead_check']){$sr = 60;}
						if ($v['cou_check']){$sr = 80;}
						if ($v['admin_check'] && $v['leave_state']==1){$sr = 100;}
					?>
						<tr class="text-c">
							<td><?php echo $v['leave_id'];?></td>
							<td class="text-c"><?php echo substr($v['create_time'],0,-9);?></td>
							<td class="text-c"><?php echo $v['stu_name'];?></td>
							<td class="text-c"><?php echo $v['leave_starttime'];?></td>
							<td class="text-c"><?php echo $v['leave_endtime'];?></td>
							<td><?php echo $v['leave_duration'];?></td>
							<td><?php if($v['type']==1){echo "事假";}else{echo '病假';}?></td>
							<td class="text-c">
							<?php if ($v['ass_check']==0){?>
								<span class='label radius' id='<?php echo $v['leave_id'];?>'>待审核</span>
							<?php }else if($v['ass_check']==1){?>
								<span class='label label-success' id='<?php echo $v['leave_id'];?>'>通过</span>
							<?php }else{?>
								<span class='label label-warning radius' id='<?php echo $v['leave_id'];?>'>拒绝</span>
							<?php }?>
							
							</td>
							<td class="td-manage">
								<a style="text-decoration:none" class="ml-5" onClick="leave_edit('请假单查看','leave_pre.php?id=<?php echo urlencode($v['leave_id']);?>','10001')" href="javascript:;" title="查看"><i class="Hui-iconfont">&#xe695;</i></a>
								<?php if ($v['ass_check']!=1){?> 
								<a style="text-decoration:none" class="ml-5" onClick="leave_check(this,<?php echo urlencode($v['leave_id']);?>,<?php echo $v['ass_check'];?>)" href="javascript:;" title="审核不通过"><i class="Hui-iconfont">&#xe6dd;</i></a>
								<a style="text-decoration:none" class="ml-5" onClick="leave_check(this,<?php echo urlencode($v['leave_id']);?>,<?php echo $v['ass_check'];?>)" href="javascript:;" title="审核通过"><i class="Hui-iconfont">&#xe6e1;</i></a>
								<?php }?>
							</td>
						</tr>
						<?php }?>
					</tbody>
				</table>
			</div>
			
      </div>
      <div class="tabCon">
      	<div class="mt-20">
				<table class="table table-border table-bordered table-bg table-hover table-sort">
					<thead>
						<tr class="text-c">
							<th width="20">ID</th>
							<th width="60">申请日期</th>
							<th width="60">姓&nbsp;&nbsp;名</th>
							<th width="60">开始时间</th>
							<th width="60">结束时间</th>
							<th width="30">申请天数</th>
							<th width="30">请假类型</th>
							<th width="30">审核状态</th>
							<th width="30">操作</th>
						</tr>
					</thead>
					<tbody>
					<?php foreach ($res as $k=>$v){ 
						$sr=0;
						if ($v['ass_check']){$sr = 20;}
						if ($v['man_check']){$sr = 40;}
						if ($v['lead_check']){$sr = 60;}
						if ($v['cou_check']){$sr = 80;}
						if ($v['admin_check'] && $v['leave_state']==1){$sr = 100;}
					?>
						<tr class="text-c">
							<td><?php echo $v['leave_id'];?></td>
							<td class="text-c"><?php echo substr($v['create_time'],0,-9);?></td>
							<td class="text-c"><?php echo $v['stu_name'];?></td>
							<td class="text-c"><?php echo $v['leave_starttime'];?></td>
							<td class="text-c"><?php echo $v['leave_endtime'];?></td>
							<td><?php echo $v['leave_duration'];?></td>
							<td><?php if($v['type']==1){echo "事假";}else{echo '病假';}?></td>
							<td class="text-c">
							<?php if ($v['ass_check']==0){?>
								<span class='label radius' id='<?php echo 'qb'.$v['leave_id'];?>'>待审核</span>
							<?php }else if($v['ass_check']==1){?>
								<span class='label label-success' id='<?php echo 'qb'.$v['leave_id'];?>'>通过</span>
							<?php }else{?>
								<span class='label label-warning radius' id='<?php echo 'qb'.$v['leave_id'];?>'>拒绝</span>
							<?php }?>
							
							</td>
							<td class="td-manage">
								<a style="text-decoration:none" class="ml-5" onClick="leave_edit('请假单查看','leave_pre.php?id=<?php echo urlencode($v['leave_id']);?>','10001')" href="javascript:;" title="查看"><i class="Hui-iconfont">&#xe695;</i></a>
							</td>
						</tr>
						<?php }?>
					</tbody>
				</table>
			</div>
			
      </div>
      
    </div>
			
			
		</article>
	</div>
</section>



<!--_footer 作为公共模版分离出去-->
<?php require_once 'comm/_footer.php';?>
<!--/_footer /作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
$('.table-sort').dataTable({
	"aaSorting": [[ 1, "desc" ]],//默认第几个排序
	"bStateSave": true,//状态保存
	"aoColumnDefs": [
	  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
	  {"orderable":false,"aTargets":[0,6]}// 制定列不参与排序
	]
});
/*-添加*/
function leave_add(title,url){
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}


/*请假审核*/
function leave_check(obj,id,state){
	var x_msg = obj.title;
	
	layer.confirm(x_msg,function(index){
		$.ajax({
			url:'comm/leave_check.php',
			data:{leave_id:id,check:state,check_name:'ass_check'},
			type:"POST",
			success:function(msg){
				alert(msg);
				if(msg==1){
					//更改为审核通过
					$('#qb'+id).removeClass("label radius").addClass("label label-success");
					$('#qb'+id).text('通过');
					$(obj).parents("tr").remove();
					layer.msg('审核通过！',{icon:1,time:1000});
				}else if(msg==3){
					//拒绝
					$('#qb'+id).removeClass("label radius").addClass("label label-warning radius");
					$('#qb'+id).text('不通过');
					$(obj).parents("tr").remove();
					layer.msg('审核不通过！',{icon:1,time:1000});
				}else{
					layer.msg('操作失败！',{icon:2,time:1000});
				}
			},
			error:function(){
				layer.msg('操作错误！',{icon:3,time:1000});
			}
		});
	});
}


//选项卡切换
$("#tab_demo").Huitab({
	tabEvent:"mousemove",
	index:0
});
$("#tab_demo").Huitab({
	tabEvent:"mousemove",
	index:2
});
$("#tab_demo").Huitab({
	tabEvent:"mousemove",
	index:0
});
//$(function(){
//	$.Huitab("#tab_demo .tabBar span","#tab_demo .tabCon","current","mousemove","1")});
</script>
<!--/请在上方写此页面业务相关的脚本-->
<!--/请在上方写此页面业务相关的脚本-->

</body>
</html>